package com.bole.controller;

import com.alibaba.fastjson.JSONObject;
import com.bole.data.Result;
import com.bole.data.ResultEnum;
import com.bole.dto.car.TbCarDto;
import com.bole.feign.CarFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("car")
@Api(value = "车辆信息管理api")
public class CarController {

    @Autowired
    private CarFeign carFeign;

    @Resource
    private RocketMQTemplate rocketMQTemplate;

    @RequestMapping("toCar")
    public String carSeriesList(){
        return "/car/car_exam_list";
    }


    @GetMapping("getCarInfo")
    @ResponseBody
    @ApiOperation(value = "查询车辆", notes = "查询车辆")
    public Result getCarInfo() {
        List<TbCarDto> carInfo = carFeign.getCarInfo();
        return Result.response(ResultEnum.OK).setData(carInfo);
    }

    @PostMapping("updateCar")
    @ResponseBody
    //审核通过为1 未通过2
    @ApiOperation(value = "修改状态为审核成功", notes = "修改状态为审核成功")
    @ApiImplicitParam(name = "ids[]", value = "ids", required = true, dataTypeClass = Long.class)
    public Result saveContentCateInfo(@RequestParam("ids[]") Long[] ids) {
       //carFeign.saveContentCateInfo(ids);
       String s = JSONObject.toJSONString(ids);
       rocketMQTemplate.convertAndSend("BOLE",s);
       return Result.response(ResultEnum.OK);
    }
}
